<template>
  <el-dialog
    title="骑手配送设置"
    width="60%"
    class="el-dialog-box"
    :visible.sync="dialogVisible"
    @close="closeDialog"
  >
    <div class="edit-label-content">
      <div class="container">
        <el-form :inline="true" :model="form" class="demo-form-inline">
          <el-form-item
            label="配送时间"
            :rules="[{ required: true, message: '不能为空' }]"
          >
            <el-input-number v-model="form.time" :max="120" :precision="0" :step="1" placeholder="请输入">
            </el-input-number>
            <span style="margin-left: 10px;">分钟</span>

          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- 按键 -->
    <span slot="footer" class="dialog-footer">
      <div class="default-btn" @click="save">
        {{ $t("user.preservation") }}
      </div>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        dialogVisible: false,
        form: {
          time: "",
        },
      };
    },
    mounted() {},
    methods: {
      open(id, payload) {
        this.id = id;
        this.$http({
          url: this.$http.adornUrl("/sys/pconfig/info/" + "RIDER_DELIVERY_TIME"),
          method: "get",
          params: this.$http.adornParams(),
        }).then(({ data }) => {
          if (data) {
            this.form.time = JSON.parse(data);
          }
        });

        this.dialogVisible = true;
      },
      save() {
        if(!this.form.time && this.form.time!== 0){
          this.$message.warning(this.$i18n.t('formData.timeCannotBeEmpty'))
          return
        }
        this.$http({
          url: this.$http.adornUrl("/sys/pconfig/save"),
          method: "post",
          data: this.$http.adornData({
            paramKey: "RIDER_DELIVERY_TIME",
            paramValue: JSON.stringify(this.form.time),
            remark: "配送设置",
          }),
        }).then(({ data }) => {
          this.$message({
            message: this.$i18n.t("publics.operation"),
            type: "success",
            duration: 1500,
          });
        });
        // this.$http({
        //   url: this.$http.adornUrl("/platform/rider/send-minutes" + this.id),
        //   method: "put",
        // }).then(({ data }) => {
        //   this.infoForm = data;
        // });
        this.dialogVisible = false;
      },
      closeDialog() {
        this.form.time = "";
      },
      handleInput(){
        this.form.time = this.form.time.replace(/[^0-9]/g, '');
        console.log('this.form.time',this.form.time);
      }
    },
  };
</script>

<style lang="scss" scoped>
  .container {
    font-size: 14px;
  }
</style>
